Skip to content

Conversation

@Pyrodash
Copy link
Contributor

No description provided.

@monkey92t
Copy link
Collaborator

monkey92t commented Oct 22, 2021

First of all, during Scan, we cannot know the unit of the return value. For example, the units of TTL and PTTL are different. In addition, for the value set by the user, we cannot take it for granted that it is nanoseconds (time.Duration(n) ).

In the writeArg command, we will not write the time.Duration type, because there is no time.Duration in redis, it is just the type of go.

@vmihailenco
Copy link
Collaborator

I guess this is for Set and Get

rdb.Set(ctx, "foo", time.Second, 0)

var d time.Duration
rdb.Get(ctx, "foo").Scan(&d)

// or

rdb.Get(ctx, "foo").Duration()

Probably this is fine, but @Pyrodash please add a test and change commit to follow https://www.conventionalcommits.org/en/

@vmihailenco
Copy link
Collaborator

Fixes #1929

@Pyrodash
Copy link
Contributor Author

I guess this is for Set and Get

rdb.Set(ctx, "foo", time.Second, 0)

var d time.Duration
rdb.Get(ctx, "foo").Scan(&d)

// or

rdb.Get(ctx, "foo").Duration()

Probably this is fine, but @Pyrodash please add a test and change commit to follow https://www.conventionalcommits.org/en/

Yes, this is my intended use case.
I've added a test case, the commit is passing the linter so I think it's fine?

@Pyrodash Pyrodash changed the title Add support for time.Duration write and scan feat: add support for time.Duration write and scan Oct 22, 2021
@vmihailenco
Copy link
Collaborator

Thanks

@vmihailenco vmihailenco merged commit a52a508 into redis:master Oct 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants